<?php

namespace app\admin\model\insurance;

use think\Model;


class Items extends Model
{

    

    

    // 表名
    protected $name = 'insurance_items';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    public static function add($order_id, $data)
    {
        $model = new static;
        $item=$model->get(['order_id'=>$order_id]);
        if($item){
            self::where('order_id', $order_id)->delete();
        }
         foreach ($data as $key => $value) {
                $res = $model->allowField(true)->save(array_merge($value, compact('order_id')));
        }
        return $res ? $model : false;
    }

    







}
